#ifndef COMMON_GRAPHICS_VERTEX_BUFFER_H
#define COMMON_GRAPHICS_VERTEX_BUFFER_H


#include "GraphicsResource.h"


struct VertexElement
{
    enum Attribute
    {
        kPosition,
        kNormal,
        kTangent,
        kBitangent,
        kTexCoord0,
        kTexCoord1,
        kTexCoord2,
        kColour0,

        kAttributeCount
    };

    enum Type
    {
        kFloat,

        kInvalid
    };

    VertexElement() : offset(0), attribute(kAttributeCount), count(0), type(kInvalid) { }
    VertexElement(size_t offset, Attribute attribute, size_t count, Type type) : offset(offset), attribute(attribute), count(count), type(type) { }

    Attribute   attribute;
    size_t      offset;
    size_t      count;
    int         type;
};


class VertexBuffer : public GraphicsResource
{
public:
    enum Usage
    {
        kStatic,
        kStreaming,
        kDynamic
    };
                            VertexBuffer(Usage usage, const VertexElement* elements, size_t elementCount, size_t vertexStride, size_t vertexCount);
                            ~VertexBuffer();

    size_t                  GetVertexStride() const;
    size_t                  GetVertexCount() const;
    const VertexElement*    GetElements() const;

private:
    size_t          stride;
    size_t          vertexCount;
    VertexElement   elements[VertexElement::kAttributeCount];
};


void BindVertexBuffer(const VertexBuffer* buffer);
void SetVertexData(const VertexBuffer* buffer, const void* vertexData, size_t vertexOffset, size_t vertexCount);


#endif
